package com.heima.wemedia.controller;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmNewsDto;
import com.heima.model.wemedia.dtos.WmNewsPageReqDto;
import com.heima.wemedia.service.WmNewsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author jack
 * @data 2024 9:47
 */
@RestController
@Slf4j
@RequestMapping("/api/v1/news")
public class WmNewsController {

    @Autowired
    private WmNewsService wmNewsService;

    /**
     * 查询文章列表
     *
     * @return
     */
    @PostMapping("list")
    public ResponseResult list(@RequestBody WmNewsPageReqDto reqDto) {
        return wmNewsService.queryByPageWithConditions(reqDto);
    }

    /**
     * 发布文章
     *
     * @return
     */
    @PostMapping("submit")
    public ResponseResult submit(@RequestBody WmNewsDto wmNewsDto){
        return wmNewsService.submit(wmNewsDto);
    }

    /**
     * 文章上下架
     *
     * @param map
     * @return
     */
    @PostMapping("down_or_up")
    public ResponseResult downOrUp(@RequestBody Map<String,Object> map){
        return wmNewsService.downOrUp(map);
    }

    /**
     * 查询文章列表
     * @param wmNewsPageReqDto
     * @return
     */
    @PostMapping("list_vo")
    public ResponseResult listVo(@RequestBody WmNewsPageReqDto wmNewsPageReqDto) {
        return wmNewsService.listVo(wmNewsPageReqDto);
    }
    /**
     * 查看文章详情
     */
    @GetMapping("/one_vo/{id}")
    public ResponseResult OneVo(@PathVariable("id") Integer id) {
        return wmNewsService.queryOneVo(id);
    }

    /**
     * 人工审核成功
     * @param wmNewsDto
     * @return
     */
    @PostMapping("/auth_pass")
    public ResponseResult authPass(@RequestBody WmNewsDto wmNewsDto) {
        return wmNewsService.authPass(wmNewsDto);
    }
    /**
     * 人工审核失败
     * @param wmNewsDto
     * @return
     */
    @PostMapping("/auth_fail")
    public ResponseResult authFail(@RequestBody WmNewsDto wmNewsDto) {
        return wmNewsService.authFail(wmNewsDto);
    }
}
